package com.example.mobile2021606128wje0615;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql="create table student(_id integer primary key autoincrement,name varchar(20) not null,age integer,socre float)";
        db.execSQL(sql);
        ContentValues values=new ContentValues();
        values.put("name","王小平");
        values.put("age",20);
        values.put("score",88);
        db.insert("users",null,values);
        values.put("name","黄小华");
        values.put("age",19);
        values.put("score",96);
        db.insert("users",null,values);
        values.put("name","张小玲");
        values.put("age",20);
        values.put("score",99);
        db.insert("users",null,values);


    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
